#include "Cubes.h"
#include<string>
#include <iostream>
using namespace std;

int main()
{
	string word;
	cin>>word;
	int count;
	cin>>count;
	vector<string> input;
	string current;
	for( int i = 0; i < count; i++ ) {
		cin>>current;
		input.push_back(current);
	}
	CCubes cubes( input, word );
	if( cubes.GetResult() == word.size() )
		cout<<"YES"<<'\n';
	else
		cout<<"NO"<<'\n';
	vector<int> result = cubes.Cubes();
	for( int i = 0; i < result.size(); i++ ) {
		cout<<input[i]<<'\n';
	}
	return 0;
}